package service

import (
	"fmt"
	"rongyy/src/models"
)

type SurveyService struct {
}

// Create
//
//	@Description: 查询卡
//	@receiver pc
//	@param req
//	@return *models.Resp3013
//	@return error
func (pc *SurveyService) Create(req *models.SurveyModel) error {
	//
	sm := &models.SurveyModel{}
	err := sm.Create(req)
	return err
}
func (pc *SurveyService) GetSurvey(req *models.ReqSurvey) ([]models.SurveyModel, int64, error) {
	sm := &models.SurveyModel{}
	data, total, err := sm.GetSurvey(req)

	if total == 0 {
		return nil, total, fmt.Errorf("暂无数据")
	}
	i := 0
	for i = 0; i < len(data); i++ {
		dd := data[i].Data
		k := 0
		for k = 0; k < len(dd); k++ {
			if dd[k].Answer == "满意" || dd[k].Answer == "很满意" {
				data[i].CountMy++
			}
			if dd[k].Answer == "一般" {
				data[i].CountYb++
			}
			if dd[k].Answer == "不满意" || dd[k].Answer == "很不满意" {
				data[i].CountBmy++
			}
		}
	}
	return data, total, err
}
